﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<?php
        $cnk=$_SESSION['cnk']; 
        $sql=mysql_query("select * from khoa where username='$cnk'");
		$r=mysql_fetch_row($sql);
		$tenkhoa=$r[1];
		$makhoa=$r[0];
?>
<body>
<table border="0" align="center">
     <tr>
	     <td height="100">&nbsp;
		        
		 </td>
	 </tr>
     <tr>
	      <td>
					<form name="f" method="post" >
									  <table width="400"  border="0"  align="center" style="border:1px solid #0066FF" cellpadding="0" cellspacing="0">
									  
									  
											<tr bordercolor="#FFFFFF"> 
												  <td height="35" colspan="2" align="center" background="image/bg_header.gif">
									<span style="font-size:24px; color:#FFFFFF; font-weight:bold;">Kết Quả Đánh Giá Học Phần </span>
												 </td>
											
											</tr>
											
											<tr height="10"  bordercolor="#FFFFFF" >  
												  <td   align="center" colspan="2">
											
												  </td>
													
											</tr>
											<tr height="30"  bordercolor="#FFFFFF" >  
												  <td  style="font-size:18px; " align="center" width="200">
														Học Kì:
												  </td>
												  <td  align="left" width="200">
														<select name="hk" id="hk" >
																   
														 <?php 
																$sql=mysql_query("select distinct (hocki) from `hocki nienkhoa` where hocki != (select hocki from `hocki nienkhoa` where ma_hknk=(select max(ma_hknk) from `hocki nienkhoa`)) "); 
																 while($r=mysql_fetch_row($sql))
																 {
																	
																	$hk=$r[0];
																	
														 ?>
																	<option ><?php echo  $hk; ?> </option>
														<?php 
																 }//ngoac while
														?>
														<?php         $sql1=mysql_query("select * from `hocki nienkhoa` where ma_hknk=(select max(ma_hknk) from `hocki nienkhoa`)");
																	  $r1=mysql_fetch_row($sql1);
																	  $hk=$r1[1];
														?>
																 <option  selected="selected"><?php  echo $hk;?> </option>
																   
														</select>
												  </td>
												  
											</tr>
											<tr height="30"  bordercolor="#FFFFFF" >  
												  <td  style="font-size:18px;" align="center" width="200" >
														Niên Khóa:
												  </td>
												  <td align="left" >
														<select name="nk" id="nk">
																  <?php
																$sql=mysql_query("select distinct(nienkhoa)  from `hocki nienkhoa` where nienkhoa != (select nienkhoa  from `hocki nienkhoa` where ma_hknk=(select max(ma_hknk) from `hocki nienkhoa`)) "); 
																 while($r=mysql_fetch_row($sql))
																 {
																	
																	$nk=$r[0];
														 ?>
																	<option ><?php echo  $nk; ?> </option>
														<?php 
																 }//ngoac while
														?>
														<?php         $sql1=mysql_query("select *  from `hocki nienkhoa` where ma_hknk=(select max(ma_hknk) from `hocki nienkhoa`)");
																	  $r1=mysql_fetch_row($sql1);
																	  $nk=$r1[2];
														?>
																 <option  selected="selected"><?php  echo $nk;?> </option> 
														</select>
												  </td>
												  
											</tr>
											
											<tr height="30"  bordercolor="#FFFFFF" >  
												  <td  style="font-size:18px;" align="center" width="200" >
														Bộ Môn:
												  </td>
												  <td align="left" >
														<select name="bm" id="bm">
																  <?php
																$sql=mysql_query("select ma_bm,ten_bm from `bo mon` where ma_khoa='$makhoa' "); 
																 while($r=mysql_fetch_row($sql))
																 {
																	
																	$mabm=$r[0];
																	$tenbm=$r[1];
														 ?>
																	<option value="<?php echo $mabm; ?>"><?php echo  $tenbm; ?> </option>
														<?php 
																 }//ngoac while
														?>
														            <option value="tatca">Tất cả</option>
																
														</select>
												  </td>
												  
											</tr>
											
											<tr height="30"  bordercolor="#FFFFFF" >  
												  <td   align="center" colspan="2">
														<input type="submit" name="xem" value="Xem Kết Quả" />
												  </td>
													
											</tr>				
											<tr height="10"  bordercolor="#FFFFFF" >  
												  <td   align="center" colspan="2">
											
												  </td>
													
											</tr>	
										   
									</table>
					</form>
				</td>
			</tr>
</table>
<?php
       if(isset($_POST["xem"]))
	   {
	           
								$hocki=$_POST["hk"]; 
								$nienkhoa=$_POST["nk"];
								$mabm=$_POST["bm"]; 
								$nienk="$nienkhoa";
								$str=mysql_query("select * from `hocki nienkhoa` where hocki='$hocki' and nienkhoa = '$nienk' ");
							    $t=mysql_fetch_array($str);
								$hknk=$t[0];
								if($mabm=="tatca")
								{
								     echo "<meta http-equiv='refresh' content='0; URL=cnk-tcxem.php?nav=kqbmtc&ma=$hknk ' />";
								}
								else
								{
									$tam=mysql_query("select  distinct(c.ma_hp),b.ten_hp from  `hoc phan` b, `lop hoc phan` c,`giang vien` d, `bo mon` e where  c.ma_hknk = '$hknk' and b.ma_hp=c.ma_hp and c.ma_gv=d.ma_gv and d.ma_bm=e.ma_bm and e.ma_khoa='$makhoa' and e.ma_bm='$mabm'  ");
									$count=mysql_num_rows($tam);
									if($count==0)
									   {
											 echo "<script language='Javascript'>alert('Khong co du lieu de tim!')</script>";
											 echo "<meta http-equiv='refresh' content='0;URL=cnk-tcxem.php?nav=bm'>";
									   }
									else
										echo "<meta http-equiv='refresh' content='0; URL=cnk-tcxem.php?nav=kqbm&ma=$hknk&&bm=$mabm ' />";
								}
							
	   }//ngoac if
?>
</body>
</html>
